using System;
using System.Collections.Generic;
using System.Linq;
using RMH.Entities;
using RMH.Services;

namespace RMH.Web.FakeServices
{
    public class FakePatientService : IPatientService
    {
        private static List<Patient> _patients = new List<Patient>
                                                         {
                                                             new Patient(){Id = 1, LastName = "Smith", FirstName = "Joey", DateOfBirth = new DateTime(2002, 5, 20),
                                                             PhoneNumber = "(517) 555-1234", Address = new Address(){Street1 = "1 Main St", City = "Lansing", State = "MI", PostalCode = "12345"},
                                                             Diagnoses = new List<Diagnosis>{(new FakeDiagnosisService()).Get(1), (new FakeDiagnosisService()).Get(3)}},
                                                             new Patient(){Id = 2, LastName = "Johnson", FirstName = "Billy", DateOfBirth = new DateTime(1999, 3, 2),
                                                             PhoneNumber = "(517) 654-1234", Address = new Address(){Street1 = "1 Oak St", City = "Detroit", State = "MI", PostalCode = "12346"},
                                                             Diagnoses = new List<Diagnosis>{(new FakeDiagnosisService()).Get(1), (new FakeDiagnosisService()).Get(4)}},
                                                             new Patient(){Id = 3, LastName = "Anderson", FirstName = "Tobey", DateOfBirth = new DateTime(1996, 7, 14),
                                                             PhoneNumber = "(517) 123-1234", Address = new Address(){Street1 = "1 Maple St", City = "Bay City", State = "MI", PostalCode = "24687"},
                                                             Diagnoses = new List<Diagnosis>{(new FakeDiagnosisService()).Get(2), (new FakeDiagnosisService()).Get(3)}},
                                                             new Patient(){Id = 4, LastName = "Bailey", FirstName = "Johnny", DateOfBirth = new DateTime(2000, 5, 5),
                                                             PhoneNumber = "(517) 765-1234", Address = new Address(){Street1 = "1 Birch St", City = "Traverse City", State = "MI", PostalCode = "62486"},
                                                             Diagnoses = new List<Diagnosis>{(new FakeDiagnosisService()).Get(1), (new FakeDiagnosisService()).Get(3)}},
                                                             new Patient(){Id = 5, LastName = "Doe", FirstName = "Timmy", DateOfBirth = new DateTime(2006, 6, 30),
                                                             PhoneNumber = "(517) 343-1234", Address = new Address(){Street1 = "1 Elm St", City = "Kalamazoo", State = "MI", PostalCode = "66823"},
                                                             Diagnoses = new List<Diagnosis>{(new FakeDiagnosisService()).Get(1), (new FakeDiagnosisService()).Get(2)}},
                                                             new Patient(){Id = 6, LastName = "Harvey", FirstName = "Lily", DateOfBirth = new DateTime(2008, 5, 20),
                                                             PhoneNumber = "(517) 876-1234", Address = new Address(){Street1 = "1 Main St", City = "Flint", State = "MI", PostalCode = "98765"},
                                                             Diagnoses = new List<Diagnosis>{(new FakeDiagnosisService()).Get(2), (new FakeDiagnosisService()).Get(3)}},
                                                             new Patient(){Id = 7, LastName = "Washington", FirstName = "Sally", DateOfBirth = new DateTime(2001, 4, 1),
                                                             PhoneNumber = "(517) 555-1234", Address = new Address(){Street1 = "1 Market St", City = "Ann Arbor", State = "MI", PostalCode = "34523"},
                                                             Diagnoses = new List<Diagnosis>{(new FakeDiagnosisService()).Get(3), (new FakeDiagnosisService()).Get(4)}},
                                                             new Patient(){Id = 8, LastName = "Adams", FirstName = "Tammy", DateOfBirth = new DateTime(2003, 12, 28),
                                                             PhoneNumber = "(517) 888-1234", Address = new Address(){Street1 = "1 Main St", City = "Lansing", State = "MI", PostalCode = "54321"},
                                                             Diagnoses = new List<Diagnosis>{(new FakeDiagnosisService()).Get(1)}}
                                                         };

        #region IPatientService Members

        public IList<Patient> GetAll()
        {
            return _patients;
        }

        public IList<Patient> Search(string firstName, string lastName)
        {
            return _patients.Where(p => (String.IsNullOrEmpty(firstName) || p.FirstName == firstName) && (String.IsNullOrEmpty(lastName) || p.LastName == lastName)).ToList();
        }

        public Patient Get(int id)
        {
            return _patients.Where(p => p.Id == id).FirstOrDefault();
        }

        public void Save(Patient patient)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}